package blockworld;

import java.awt.Point;

public class MoveAction 
{
	private Point _from;
	private Point _to;
	private int _direction;
	private String _agentName;
	
	
	public MoveAction(Point from, int direction, String agentName)
	{
		this._from = from;
		this._to = calculateDestination(from,direction);
		this._direction = direction;
		this._agentName = agentName;
	}
	
	public Point getFrom()
	{
		return _from;
	}
	
	public Point getTo()
	{
		return _to;
	}
	
	public int getDirection()
	{
		return _direction;
	}
	
	public String getAgentName()
	{
		return _agentName;
	}
	
	
	public Point calculateDestination(Point from, int direction)
	{
		Point destination = new Point(from);
		if(direction == Direction.NORTH)
		{
			destination.y++;
		}else if(direction == Direction.EAST)
		{
			destination.x++;
		}else if(direction == Direction.SOUTH)
		{
			destination.y--;
		}else if(direction == Direction.WEST)
		{
			destination.x--;
		}
		return destination;
	}
}

